package com.lingyistudio.blog.controller;

import com.lingyistudio.blog.entity.BlogFront;
import com.lingyistudio.blog.service.BlogService;
import com.lingyistudio.common.response.WebResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author :  LingYi
 * @ClassName : SysController
 * @Date :   2019/7/29 17:21
 */

@RestController
@RequestMapping("blog")
public class BlogController {

    @Autowired
    BlogService blogService;

    @PostMapping("addBolg")  //增加文章
    public WebResponse addBlogController(BlogFront blogFront){
        return blogService.addBlogService(blogFront);
    }

    @GetMapping("allBlog")  //获取所有人的文章
    public WebResponse allBlogController(){
        return blogService.findallBlog();
    }

    @GetMapping("PeopleAllBlog") //获取某人的博客
    public WebResponse PeopleAllBlogController( BlogFront blogFront){
        return blogService.findallBlogNeedCreateByService(blogFront);
    }

    @GetMapping("IsUsedBlog") //是否发表文章
    public WebResponse updateBlogIsUsedController( BlogFront blogFront){
        return blogService.updateBlogIsUsed(blogFront);
    }

    @GetMapping("IsDeteledBlog") //删除文章
    public WebResponse updateBlogIsDeteledController( BlogFront blogFront){
        return blogService.updateBlogIsDeteled(blogFront);
    }

    @GetMapping("findOneBlog") //查询某篇文章
    public WebResponse findOneBlogController( BlogFront blogFront){
        return blogService.findOneBlogService(blogFront);
    }

    @GetMapping("updateBlog") //修改文章
    public WebResponse updateBlogController( BlogFront blogFront){
        return blogService.updateBlogService(blogFront);
    }



}
